<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="template.js" ></script>
<script id="muban1" type="text/html">
	{{if c>10}}
		<h1>{{title}}</h1>
		<p>{{content}}</p>
	{{else if d<5 }}
		<ul>
			{{each arr as v ind}}
				<li>{{v+" "+ind}}</li>
			{{/each}}
		</ul>
	{{else}}
		<ul>
			{{each obj as v ind}}
				<li>{{v+" "+ind}}</li>
			{{/each}}
		</ul>
	{{/if}}
</script>
</head>
<body>
	<div id="div1"></div>
	<script>
		//	定义数据
		var data = {
			title : "这是标题",
			content : "这是内容",
			b : false,
			arr : ["aaa","bbb","ccc","ddd"],
			c : 10,
			d : 5,
			obj : {
				"name":"zhangfei",
				"age":"18",
				"sex":"nan"
			}
		}
		//  使用模版
		var html = template("muban1",data);//使用muban1
		document.getElementById("div1").innerHTML = html;
	</script>
</body>
</html>
